<%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator" prefix="decorator" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ page contentType="text/html; charset=UTF-8" %>
<decorator:usePage id="mainPage" />
<html>
<head>
<link href="<s:url value='/css/not-ie.css' />" rel="stylesheet" type="text/css">
<script language="javascript" src="<s:url value='/js/control.js' />"></script>
<script type="text/javascript" src="<s:url value='/jquery-ui-1.10.3.custom/js/jquery-1.9.1.js' />" ></script>
<script type="text/javascript" src="<s:url value='/jquery-ui-1.10.3.custom/js/jquery-ui-1.10.3.custom.js' />" ></script>
<link rel="stylesheet" href="<s:url value='/jquery-ui-1.10.3.custom/css/ui-lightness/jquery-ui-1.10.3.custom.css' />" />


<script language="javascript">
$(function(){
	$("#datepicker").datepicker({
		dateFormat:"dd/mm/yy"
		});
});
function sf(){
	new  NumberControl();
	if(jQuery("[name='page']").val()=="view"){		
		document.getElementById("btnCancel").focus();
	}else{
		document.getElementsByName("remove.areaId")[0].focus();
	}
}
function savePage(){
	frm =document.removeAddForm;
	if(!validate('removeAddForm','<s:text name="0003" />')){
		return false;
	}

	if(jQuery("[name='page']").val()=="add"){
		frm.action="<s:url value='/jsp/user/addRemove.action'/>";
	}else{
		frm.action="<s:url value='/jsp/user/editRemove.action'/>";
	}
		frm.submit();
	
}
function validate(formId, msg){
	var eles = jQuery("#"+formId+" .requireInput");
	for(var i=0;i < eles.length;i++){
		if(!eles[i].disabled && eles[i].value ==''){
			alert(msg);
			eles[i].focus();
			return false;
		}
	}
	return true;
}
function gotoSearch(){
	frm = document.removeAddForm;
	if(frm["criteriaKey"].value == ""){
		frm.action="<s:url value='/initRemove.action'/>";
		frm.submit();
	}else{
		frm.action="<s:url value='/searchRemove.action'/>";
		frm.submit();
	}
}

</script>
<style type="text/css">
	.tab-bar {
		width: 100%; 
		height: 100px; 
		overflow: hidden;
	}
	.tab-body {
		float: left;
		width: 100%; 
		vertical-align: top; 
		overflow: hidden;
	}
</style>
</head>

<body onload="javascript:sf();">
<s:if test="page=='add'">
<h1>เพิ่มข้อมูลรื้อถอน</h1>
</s:if>
<s:elseif test="page=='edit'">
<h1>แก้ไขข้อมูลรื้อถอน</h1>
</s:elseif>
<s:else>
<h1>แสดงข้อมูลรื้อถอน</h1>
</s:else>
<s:form id="removeAddForm" onsubmit="return savePage();" method="post" theme="simple" name="removeAddForm" cssClass="margin-zero">
<table class="authen">
		<tr>
			<td class="left">
			</td>
			<td class="center"><s:property value="#request.message" /></td>
			<td class="right"></td>
		</tr>
	</table>
	<table class="form">
		<tr style="height: 0px;">
			<td class="col-width-100px"></td>
			<td class="col-width-175px"></td>
			<td class="col-width-175px"></td>
			<td class="col-width-125px"></td>
			<td class="col-width-175px"></td>
			<td class="col-width-auto"></td>
		</tr>
		
		<tr><td></td> </tr>

		<tr>
			<td></td>
			<td align="right">แปลง&nbsp;<font  color="red">*</font >&nbsp;</td>
			<td><s:select name="remove.plantingId" 
				headerKey=""
				headerValue="" 
				cssClass="requireInput"
				list="lstArea" 
				size="1" 
				cssStyle="width:150px;"
				disabled="%{page=='view'}"/>
			</td>
			<td align="right">วันที่รื้อถอน&nbsp;<font  color="red">*</font >&nbsp;</td>
			<td><s:textfield name="remove.removeDate" id="datepicker" cssClass="input_number requireInput"  disabled="%{page=='view'}"/>
		</tr>
	</table>

<table class="button">
	<tr>
		<td class="left"></td>
		<td class="right">
		<s:if test="page=='add'">
			<input type="button" id="btnSave"  onclick="savePage();" value="<s:text name="save"></s:text>" />
		</s:if>
		<s:elseif test="page=='edit'">
			<input type="button" id="btnSave"  onclick="savePage();" value="<s:text name="edit"></s:text>" />
		</s:elseif>
	 		<input type="button" id="btnCancel"  onclick="gotoSearch();" value="<s:text name="cancle"></s:text>" />
		</td>
	</tr>
</table>
<s:hidden name="criteriaKey"/>
<s:hidden name="page"/>
<s:hidden name="remove.removeId"/>
<s:token/>
</s:form>
</body>
</html>